package com.atguigu.tingshu.user.ItemTypeStrategy;

import com.atguigu.tingshu.common.execption.GuiguException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class PaidBeanFactory {
    @Autowired
    Map<String, ItemTypeStrategy> map;
    public ItemTypeStrategy getBean(String key) {
        ItemTypeStrategy itemTypeStrategy = map.get(key);
        if (itemTypeStrategy == null) {
            throw new GuiguException(400,"没有对应的策略");
        }
        log.info("itemTypeStrategy:{}", itemTypeStrategy);
        return itemTypeStrategy;
    }

}
